package com.lmiot.xyclick.Activity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.EditDialogUtil;
import com.lmiot.xyclick.Util.LogUtil;
import com.youyi.yyviewsdklibrary.View.TitleBarView;

public class ImgCropActivity extends BaseActivity implements View.OnClickListener {
    TextView mIdChose;
    TitleBarView mIdTitleBar;
    private String mImgPath;
    private Intent mIntent;

    /* access modifiers changed from: protected */
    @Override // android.support.v4.app.SupportActivity, com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_img_crop);
        initView();
        this.mIdTitleBar.setOnItemClickListener(new TitleBarView.onItemClickListener() {
            /* class com.lmiot.xyclick.Activity.ImgCropActivity.AnonymousClass1 */

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onTitleClick(View view) {
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onBackClick(View view) {
                ImgCropActivity.this.finish();
                EditDialogUtil.resumeData();
            }

            @Override // com.youyi.yyviewsdklibrary.View.TitleBarView.onItemClickListener
            public void onMenuClick(View view) {
                ImgCropActivity.this.finish();
                EditDialogUtil.resumeData();
            }
        });
        String stringExtra = getIntent().getStringExtra("imgPath");
        this.mImgPath = stringExtra;
        TextUtils.isEmpty(stringExtra);
    }

    @Override // com.lmiot.xyclick.Activity.BaseActivity, android.support.v4.app.FragmentActivity
    public void onResume() {
        super.onResume();
    }

    @Override // android.support.v4.app.FragmentActivity
    public void onActivityResult(int i, int i2, Intent intent) {
        LogUtil.d("ImgCropActivity", "requestCode:" + i + "：" + i2);
        super.onActivityResult(i, i2, intent);
        if (i2 != 0 && i == 1001) {
            try {
                intent.getData();
                LogUtil.d("ImgCropActivity", "设置图片");
            } catch (Exception e) {
                try {
                    e.printStackTrace();
                } catch (Exception e2) {
                    e2.printStackTrace();
                }
            }
        }
    }

    @Override // android.support.v7.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            finish();
            EditDialogUtil.resumeData();
        }
        return super.onKeyDown(i, keyEvent);
    }

    private void initView() {
        this.mIdTitleBar = (TitleBarView) findViewById(R.id.id_title_bar);
        TextView textView = (TextView) findViewById(R.id.id_chose);
        this.mIdChose = textView;
        textView.setOnClickListener(this);
    }

    public void onClick(View view) {
        if (view.getId() == R.id.id_chose) {
            this.mIntent = new Intent();
            if (Build.VERSION.SDK_INT < 19) {
                this.mIntent.setAction("android.intent.action.GET_CONTENT");
            } else {
                this.mIntent.setAction("android.intent.action.OPEN_DOCUMENT");
            }
            this.mIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
            startActivityForResult(Intent.createChooser(this.mIntent, "选择图片"), 1001);
        }
    }
}
